﻿Imports System.Xml

Partial Class MyDesktopCMS
    Inherits System.Web.UI.Page

    Function LoadXml(ByVal file As String) As Object

        Dim xml = Server.CreateObject("Microsoft.XMLDOM")
        xml.async = False
        xml.load(Server.MapPath(file))

        Return xml

    End Function

    Function ParseXml(ByVal file As String) As ArrayList

        Dim xml = LoadXml(Server.MapPath(file))

        Dim size = xml.documentElement.childNodes.length

        Dim myNames(size) As String
        Dim myImage(size) As String
        Dim myFiles(size) As String
        Dim myLevel(size) As String

        Dim myArrayList = New ArrayList

        myArrayList = CreateObject("System.Collections.ArrayList")

        For i = 0 To (size - 1)

            myNames(i) = getAtribute(i, "names", xml)
            myImage(i) = getAtribute(i, "image", xml)
            myFiles(i) = getAtribute(i, "files", xml)
            myLevel(i) = getAtribute(i, "level", xml)

        Next

        myArrayList.Add(myNames)
        myArrayList.Add(myImage)
        myArrayList.Add(myFiles)
        myArrayList.Add(myLevel)

        Return myArrayList

    End Function


    Function getAtribute(ByVal i As Integer, ByVal name As String, ByVal xml As Object) As String

        Dim myObject As Object = xml.documentElement
        Return myObject.childNodes(i).attributes.getNamedItem(name).nodeValue()

    End Function

End Class
